import {
	createRouter
} from '@gowiny/uni-router'
import PAGE_DATA from '@/pages.json';

// const token = uni.getStorageSync('token')
const router = createRouter({

	pageData: PAGE_DATA
})
console.log('token', uni.getStorageSync('token'))
const whiteList = ['/pages/login/login'];
router.beforeEach((to, from) => {
// 	// debugger
	console.log(whiteList.indexOf(to.path) == -1)
	if (whiteList.indexOf(to.path) !== -1) {

		if (uni.getStorageSync('token')) {
		setTimeout(() => {
			//拦截后一直跳不过去，加上定时器后就好了
			uni.switchTab({
				url: '/pages/index/index'
			});
		}, 500)
		} else {
			// setTimeout(() => {
				//拦截后一直跳不过去，加上定时器后就好了
				uni.navigateTo({
					url: '/pages/login/login'
				});
			// }, 500)
		}
	} else {

	}
})

export default router